<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1 style="color:red; background-color: green;text-align: center;">一级标题</h1>
    <p>这是一段有样式的文本</p>
    <script>
    
            //1.获取元素节点
            var h1 = document.getElementsByTagName('h1')[0];
            console.log(h1.style)
            var p = document.getElementsByTagName('p')[0];
            p.style.width= "500px";
            p.style.height = "200px";
            p.style.textAlign = "center";
            p.style.fontSize = "20px";
            p.style.color = "red";
            p.style.backgroundColor = "green";
            p.style.lineHeight = "200px";
            p.style.margin = "100px auto";
    </script>
</body>
</html>